package com.project.frba.bi.user;

public class UserQueryBuilder {
	
	public static String insertUserQuery(){
		return "INSERT INTO users(username, password, privilege) VALUES (?, ?, ?);";
	}
		
	public static String getAllUsersQuery(){
		return "SELECT u.id, u.username, u.password, p.name as privilege FROM users u INNER JOIN privileges p on u.privilege = p.id";
	}
	
	public static String getUserByIdQuery(){
		return "SELECT u.id, u.username, u.password, p.name as privilege FROM users u INNER JOIN privileges p on u.privilege = p.id WHERE u.id = ?";
	}
	
	public static String getUserByUsernameQuery(){
		return "SELECT u.id, u.username, u.password, p.name as privilege FROM users u INNER JOIN privileges p on u.privilege = p.id WHERE u.username = ?;";
	}
	
	public static String getAllUsersByPrivilegeQuery(){
		return "SELECT u.id, u.username, u.password, p.name as privilege FROM users u INNER JOIN privileges p on u.privilege = p.id WHERE u.privilege = ?";
	}
	
	public static String removeUserQuery(){
		return "DELETE FROM users WHERE id = ?";
	}
	
	public static String updateUserFieldQuery(String field){
		return "UPDATE users u SET u." + field + " = ? WHERE u.id = ?";
	}
	
	public static String updateUserQuery(){
		return "UPDATE users u SET u.username = ?, u.password = ?, u.privilege = ? WHERE u.id = ?";
	}

}
